<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
	<%@ include file="/WEB-INF/pages/weixin/include/title.jsp"%>
    <%@ include file="/WEB-INF/pages/weixin/include/include.jsp"%>
    
	<script src="${root}/res/jsLib/jquery/jquery-1.11.1.min.js"></script>
	<script src="${root}/res/jsLib/Validform_v5.3.2_min.js"></script>
	<script src="${root}/res/jsLib/ValidformExp.js"></script>
    
    <script type="text/javascript">
    	var vf;
	    $(function(){
	    	
	    	wxUtils.showToast("正在加载数据");
	    	wxUtils.loadDicData({
	    		urlFun:function(){
	    			return JSON.stringify({"method":"person","id":'${user.userid}'});
	    		},
	    		showFun:function(data){
	    			wxUtils.closeToast();
	    			wxUtils.iniScrollBar();
	    			if(data.datalist.length>0){
	    				var u = data.datalist[0];
	    				var form = $("#userForm");
	    				form.find("input[name=certificateNum]").val(u['CERTIFICATE_NUM']);
	    				form.find("input[name=email]").val(u['EMAIL']);
	    				
	    				$("#returnBtn").click(function(){
	    		    		window.location.href = wxUtils.ctx + "/weixin/login.do"; 
	    				});
	    				vf = $("#userForm").validform();
	    				$("#submitBtn").bind("click",function(){
	    		    		if(vf.check()){
	    		    			wxUtils.showToast("正在提交");
	    			    		$.post(wxUtils.ctx+"/weixin/personal/register.do",$("#userForm").serialize(),function(data){
	    			    			wxUtils.closeToast();
	    			    			if(data.success){
	    			    				wxUtils.msg(data.msg,1,function(){
	    			    					window.location.href = wxUtils.ctx + "/weixin/login.do"; 
	    			    				});
	    			    			}else{
	    			    				wxUtils.msg(data.msg,2);
	    			    			}
	    			    		},'json');
	    		    		}
	    		    	});
	    			}else{
	    				wxUtils.msg("加载个人基本信息失败，请稍后重试。",2,function(){
	    					window.location.href = wxUtils.ctx + "/weixin/login.do";
	    				});
	    			}
	    		}
	    	});
	    });
	</script>
</head>
<body>
<div class="page" style="height: 100%;">
    <div class="page__bd">
    	<div class="weui-tab__panel detail_panel">
   			<div class="weui-panel__hd" id="returnBtn" style="cursor: pointer;left:0;padding-left: 0;" position="top">&lt 返回</div>
    		<form id="userForm">
    			<input type="hidden" name="username" value="${user.username }"/>
    			<input type="hidden" name="userid" value="${user.userid }"/>
			    <div class="weui-cells weui-cells_form" position="center">
			    	<div class="weui-cells__title">账号信息</div>
		            <div class="weui-cell">
		                <div class="weui-cell__hd"><label class="weui-label">用户名</label></div>
		                <div class="weui-cell__bd">
		                    ${user.username }
		                </div>
		            </div>
		            
		            <div class="weui-cell">
		                <div class="weui-cell__hd"><label class="weui-label">密码</label></div>
		                <div class="weui-cell__bd">
		                    <input class="weui-input" type="password" name="password" dataType="*4-36" value="${user.password }"  placeholder="请输入密码"/>
		                </div>
		            </div>
		            
		            <div class="weui-cell">
		                <div class="weui-cell__hd"><label class="weui-label">确认密码</label></div>
		                <div class="weui-cell__bd">
		                    <input class="weui-input" type="password" dataType="*" recheck="password" value="${user.password }" placeholder="请再次输入密码"/>
		                </div>
		            </div>
		            
		            <div class="weui-cell">
		                <div class="weui-cell__hd"><label class="weui-label">身份证号</label></div>
		                <div class="weui-cell__bd">
		                    <input class="weui-input" type="text" name="certificateNum" dataType="*" placeholder="请输入身份证号码"/>
		                </div>
		            </div>
		            
		            <div class="weui-cell">
		                <div class="weui-cell__hd"><label class="weui-label">E-mail</label></div>
		                <div class="weui-cell__bd">
		                    <input class="weui-input" type="text" name="email" dataType="e" placeholder="请输入E-mail"/>
		                </div>
		            </div>
		            <div class="weui-btn-area">
			            <a id="submitBtn" class="weui-btn weui-btn_primary" href="javascript:void(0);" >保存修改</a>
			        </div>
		        </div>
		    </form>
    	</div>
    </div>
</div>
</body>
</html>

